(function(){
    function s_to_hs(s){
        //计算分钟
        //算法：将秒数除以60，然后下舍入，既得到分钟数
        var h;
        h  =   Math.floor(s/60);
        //计算秒
        //算法：取得秒%60的余数，既得到秒数
        s  =   s%60;
        //将变量转换为字符串
        h    +=    '';
        s    +=    '';
        //如果只有一位数，前面增加一个0
        h  =   (h.length==1)?'0'+h:h;
        s  =   (s.length==1)?'0'+s:s;
        return h+':'+s;
    }

    function getHash(key, url) {
        var hash;
        if (!!url) {
            hash = url.replace(/^.*?[#](.+?)(?:\?.+)?$/, "$1");
            hash = (hash == url) ? "" : hash;
        }
        else {
        hash = self.location.hash;
        }
        hash = "" + hash;
        hash = hash.replace(/^[?#]/, '');
        hash = "&" + hash;
        var val = hash.match(new RegExp("[\&]" + key + "=([^\&]+)", "i"));
        if (val == null || val.length < 1) {
            return null;
        } 
        else {
        return decodeURIComponent(val[1]);
        }
    }
    function getUrlParms (name) {
        let tstr = window.location.href;
        let index = tstr.indexOf('?')
        let str = tstr.substring(index + 1);
        let arr = str.split('&');
        let result = {};
        arr.forEach((item) => {
            let a = item.split('=');
            result[a[0]] = a[1];
        })
        return result[name];
    }
    
    window.getHash = getHash;
    window.s_to_hs = s_to_hs;
    window.getUrlParms = getUrlParms;
})(window)
